<template>
  <div>
    <ul class="data-container">
      <li v-for="item in list" :key="item.id">
        <div class="avatar-container">
          <Avatar
            :url="item.avatar"
            size="44"
          />
        </div>
        <div class="data">
          <div class="nickname">{{item.nickname}}</div>
          <div class="content">
            {{item.content}}
          </div>
          <div class="time">{{fromDate(item.createDate,   true)}}</div>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
import Avatar from "@/components/Avatar";
import {fromDate} from '@/utils'
export default {
  props: {
    list: {
      type: Array,
      default: () => [],
    },
  },
  methods: {
    fromDate
  },
  components: {
    Avatar,
  },
};
</script>

<style lang="less" scoped>
@import url("~@/style/var.less");
.data-container {
  list-style: none;
  margin: 0;
  padding: 0;
  li {
    display: flex;
    border-bottom: 1px solid lighten(@gray, 20%);
    padding: 15px 0;
  }
  .avatar-container {
    margin-right: 15px;
  }
  .nickname{
    color: darken(@success,10%);
    margin-bottom: 10px;
  }
  .content{
    font-size: 14px;
  }
  .data{
    position: relative;
    flex: 1 1 auto;
  }
  .time{
    position: absolute;
    right: 0;
    top: 5px;
    color: @gray;
    font-size: 12px;
  }
}
</style>